package com.atguigu.flink.chapter01_moni;

import org.apache.flink.api.common.functions.FlatMapFunction;
import org.apache.flink.api.java.tuple.Tuple2;
import org.apache.flink.util.Collector;

/**
 * Created by Smexy on 2022/10/21
 *
 *      算子功能
 */
public class MyFlatMapFunction implements FlatMapFunction<String, Tuple2<String, Integer>>
{
    @Override
    public void flatMap(String line, Collector<Tuple2<String, Integer>> out) throws Exception {
        String[] words = line.split(" ");
        for (String word : words) {
            out.collect(Tuple2.of(word, 1));
        }
    }
}
